// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-6-24

#ifndef __CHECKBOX_H_COMMON_UI__
#define __CHECKBOX_H_COMMON_UI__

#pragma once

#include "wnd.h"

class CJoyCheckBox;

//##ModelId=44CF17B901A5
class CJoyCheckGroup
{
public:
	//##ModelId=44CF17B901A7
    CList<CJoyCheckBox*>    m_boxs;
	//##ModelId=44CF17B901AB
    bool m_autoCheck;
	//##ModelId=44CF17B901B5
    bool m_autoUncheck;
public:
	//##ModelId=44CF17B901B6
    CJoyCheckGroup();
	//##ModelId=44CF17B901B7
    virtual ~CJoyCheckGroup();

	//##ModelId=44CF17B901B9
    void Add(CJoyCheckBox* box);
	//##ModelId=44CF17B901BB
    void Remove(CJoyCheckBox* box);
	//##ModelId=44CF17B901C5
    void Check(CJoyCheckBox* box);
	//##ModelId=44CF17B901C7
    void CheckFirstVisible();

	//##ModelId=44CF17B901C8
    CJoyCheckBox* GetSel();

	//##ModelId=44CF17B901C9
    void ShowAll(bool show);
};

//##ModelId=44CF17B901D4
class CJoyCheckBox :
    public CJoyCtrl
{
public:
	//##ModelId=44CF17B90237
    typedef void (CJoyWnd::*PCheckEvent)(CJoyCheckBox*, bool& checked);
protected:

    friend class CJoyCheckGroup;

	//##ModelId=44CF17B901E4
    bool    m_checked;
	//##ModelId=44CF17B901E5
    bool    m_btnDown;
	//##ModelId=44CF17B901E6
    bool    m_leftDownCheck;

	//##ModelId=44CF17B901E8
    CJoyImagePtr    m_image;
	//##ModelId=44CF17B901F5
    CJoyCheckGroup* m_group;

	//##ModelId=44CF17B901FA
    PCheckEvent     m_onCheck;
	//##ModelId=44CF17B901FF
    CJoyWnd*        m_eventCtrl;

	//##ModelId=44CF17B90203
    virtual void CM_LoadSkin(CJoyXmlElement* pSkinElem);

	//##ModelId=44CF17B90206
    virtual void CM_MouseHover();
	//##ModelId=44CF17B90208
    virtual void CM_Mouse(MouseMessage msg, const CPoint& pt);
	//##ModelId=44CF17B90214
    virtual void CM_Draw(Graphics& graph);
	//##ModelId=44CF17B90217
    virtual void CM_Destroy();

public:
	//##ModelId=44CF17B90219
    bool    m_autoUncheck;
public:
	//##ModelId=44CF17B90222
    CJoyCheckBox(void);
	//##ModelId=44CF17B90224
    virtual ~CJoyCheckBox(void);

	//##ModelId=44CF17B90227
    bool IsChecked() const
    {
        return m_checked;
    }
	//##ModelId=44CF17B90229
    CJoyCheckGroup* GetGroup() const
    {
        return m_group;
    }
	//##ModelId=44CF17B9022B
    void SetCheck(bool checked);
	//##ModelId=44CF17B90232
    void SetCheckEvent(CJoyWnd* ctrl, PCheckEvent onCheck);
	//##ModelId=44CF17B90235
    void SetImage(PCTSTR pszImage);
};


#endif  // __CHECKBOX_H_COMMON_UI__
